import { noticeList, onlinePopover, showNotice } from '@/views/desktop/missions/notice/data/data';
import type { DesktopNotice } from '@/views/desktop/missions/notice/data/type';
import { useTimeout } from '@vueuse/core';

/**
 * @description:
 *  触发通知，弹出通知栏
 *  任何通知必须转成 {DesktopNotice} 接口再发送
 * @param {DesktopNotice} item
 */
export const triggerNotice = (item: DesktopNotice) => {
  noticeList.value.unshift(item);
  showNotice.value = true;
};

/**
 * @description: 发送气泡通知
 */
export const popoverNotice = (content: string) => {
  onlinePopover.value.show = true;
  onlinePopover.value.content = `${content}`;
  useTimeout(5000, {
    callback() {
      onlinePopover.value.show = false;
    },
  });
};
